package com.niiwoo.civet.account.dao.mapper;

import com.niiwoo.civet.account.dao.entity.NiiwooBill;
import com.niiwoo.civet.account.dao.entity.NiiwooBillExample;
import com.niiwoo.civet.account.dto.bill.GroupBillAmountBySecondSubjectResponeDTO;
import com.niiwoo.civet.account.dto.common.ProjectBillCategoriesDTO;
import com.niiwoo.civet.account.dto.request.MonthBillRequestDTO;
import com.niiwoo.civet.account.dto.response.GroupAmountByDayResponseDTO;
import com.niiwoo.civet.account.dto.response.GroupAmountByMonthResponseDTO;
import com.niiwoo.civet.account.dto.response.MonthBillCountResponseDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by Jaylin on 2017/11/7.
 */
@Component
public interface NiiwooBillMapperExt extends NiiwooBillMapper{

    List<ProjectBillCategoriesDTO> listCategoriesStatis(@Param("userId") String userId, @Param("projectPackageId") Long projectPackageId);

    List<MonthBillCountResponseDTO> listMonthBillIncomeByUserId(MonthBillRequestDTO requestDTO);

    /**
     * 依据于条件统计金额
     * @param requestDTO
     * @return
     */
    MonthBillCountResponseDTO countTotalMonthAmountByCondition(MonthBillRequestDTO requestDTO);

    /**
     * 判断账户是否有交易流水用于换绑卡前置检查
     * @param userId
     * @return
     */
    NiiwooBill selectExistBillForRebindCheck(@Param("userId") String userId);

    /**
     * 根据userId和orgId查询账单
     *
     * @param userId
     * @param orgId
     * @return
     */
    NiiwooBill selectExistBillByUserIdAndOrgId(@Param("userId") String userId,@Param("orgId") String orgId);

    /**
     * 分页查询
     * @param example
     * @return
     */
    List<NiiwooBill> pageByExample(NiiwooBillExample example);

    /**
     * 按项目包分组并查询每个项目最新的账单ID
     * @param userId
     * @param firstCodes
     * @return
     */
    List<Long> listLatestBillIdGroupByPackage(@Param("userId") String userId, @Param("firstCodes")List<String> firstCodes);

    /**
     * 获取指定用户指定二级类型的金额总计
     * @param userId
     * @param secondSortCode
     * @return
     */
    BigDecimal sumAmountByUserIdAndSecondSortCode(@Param("userId") String userId, @Param("secondSortCode") String secondSortCode);

    /**
     * 统计账单金额
     * @param example
     * @return
     */
    BigDecimal sumAmountByExample(NiiwooBillExample example);

    /**
     * 按账单二级科目分组统计金额
     * @param example
     * @return
     */
    List<GroupBillAmountBySecondSubjectResponeDTO> groupAmountBySecondSubject(NiiwooBillExample example);

    /**
     * 按月或按天分组
     * @param example
     * @return
     */
    List<GroupAmountByMonthResponseDTO> groupAmountByMonth(NiiwooBillExample example);
    List<GroupAmountByDayResponseDTO> groupAmountByDay(NiiwooBillExample example);




}
